import 'dart:convert';

import 'package:get/get.dart';
import 'package:mmkv/mmkv.dart';

import '../constants.dart';
import '../models/user_info_entity.dart';

class CommonService extends GetxService {
  final mmkv = MMKV.defaultMMKV();

  String? getToken() => mmkv.decodeString(kKeyToken);

  String getRole() =>
      UserInfoEntity.fromJson(jsonDecode(mmkv.decodeString(kKeyUser)!))
                  .targetSite
                  ?.sysName ==
              'clicms'
          ? 'me'
          : 'me';

  UserInfoEntity getUser() =>
      UserInfoEntity.fromJson(jsonDecode(mmkv.decodeString(kKeyUser)!));

  bool isAssistant() =>
      UserInfoEntity.fromJson(jsonDecode(mmkv.decodeString(kKeyUser)!))
          .bossName !=
      null;

  void downloadFile(String url, String fileName) {}
}
